package net.sf.jgcs.spread;

import javax.management.MBeanServer;
import javax.management.ObjectName;

import net.sf.jgcs.ControlSession;
import net.sf.jgcs.DataSession;
import net.sf.jgcs.Protocol;
import net.sf.jgcs.Service;
import net.sf.jgcs.jmx.JmxConfigurator;

public class SpJmxConfigurator implements JmxConfigurator{

	public void register(	DataSession dataSession,
							ControlSession controlSession, 
							Service service, 
							Protocol protocol,
							MBeanServer server, 
							String domain) throws Exception {
		
		
		ObjectName name = new ObjectName(domain+"_SPProtocol");
		net.sf.jgcs.spread.jmx.SpProtocol spProtocol = new net.sf.jgcs.spread.jmx.SpProtocol((SpProtocol)protocol);
		
		server.registerMBean(spProtocol, name);
				
	}

	public void unregister(DataSession dataSession,
			ControlSession controlSession, Service service, Protocol protocol,
			MBeanServer server, String domain) throws Exception {

		ObjectName name = new ObjectName(domain+"_SPProtocol");
		server.unregisterMBean(name);
	}
	
}
